const commonTooltip = {
    trigger: 'axis',
    triggerOn: 'click',
    textStyle: {
        fontSize: 11
    },
    padding: [5, 5],
    confine: true,
    enterable: true,
    appendToBody: true,
    formatter: function (params) {
        var res = '<div style="height:auto;max-height:240px;overflow-y:auto;">';
        res += // 标题部分
            "<div style='height:24px;line-height:24px;font-size:14px;color:#000;'><p>" +
            params[0].name +
            " </p></div>";
        for (var i = 0; i < params.length; i++) {
            var value = params[i].data[i + 1]
            //先不处理 后面核对方便
            // if(typeof(value) =="undefined" ){
            //     value = 0
            // }
            //因为是个数组，所以要遍历拿到里面的数据，并加入到tooltip的数据内容部分里面去
            res += `<div style="height:18px;line-height:18px;display:flex;align-items:center;">
                <span style="margin-right:5px;border-radius:4px;width:5px;height:5px;background-color:${[params[i].color]};"></span>
                <span style="font-size:11px;color:rgba(0,0,0,0.6);">${params[i].seriesName}</span>
                <span style="width:30px;"></span>
                <span style="font-size:11px;color:#000;font-weight:500;margin-left:auto">${value}</span>
            </div>`;
        }
        res += '</div>';
        return res;
    },
}
function commonLegendFormatter(name,category) {
    return echarts.format.truncateText(name, category.length > 3 ? 80 : 160, '14px Microsoft Yahei', '…');
}

function commonXAxis(color) {
    return {
        type: 'category',
        axisLine: {
            show: true,
        },
        axisTick: {
            show: false,
        },
        splitLine: {
            show: false,
        },
        axisLabel: {
            textStyle: {
                fontSize: 10,
                color: color,
            },
            interval: 0,
            showMinLabel: true,
            showMaxLabel: true,
        }
    }
}

function commonYAxis(color) {
    return {
        type: 'value',
        axisTick: {
            show: false,
        },
        splitLine: {
            lineStyle: {
                color: 'rgb(161,161,165)',
                width: 0.1,
            },
        },
        axisLine: {

        },
        axisLabel: {
            textStyle: {
                color: color,
                fontSize: 10,
            },
            interval: 0,
            showMinLabel: true,
            showMaxLabel: true,
        },
    }
}

function commonGrid(category) {
    return {
        top: category.length > 6 ? 50 : 30,
        bottom: 0,
        left: 10,
        right: 10,
        containLabel: true,
    }
}
